﻿@model IEnumerable<Home.Site.Models.DataLayer.PhotoAlbum>
<div>
    @{
        if (Model != null)
        {
            foreach (var album in Model)
            {
        <hr />
        <div style="margin-top: 30px;">
            <div class="photo-container">
                <p class="head-album">
                    <a href="@Url.Action("Details", "Album", new { id = @album.idalbum })">
                        @album.NameAlbum
                    </a>
                </p>
            </div>
            <div class="photo-container">
                @{ var title = string.Format("Дата создания: {0}, Фотографий: {1}", album.DatePublish.ToShortDateString(), album.Photos.Count);}
                <div class="main-photo" data-title="@title">
                    @{var mainPhoto = album.Photos.FirstOrDefault();}
                    @if (mainPhoto != null)
                    {
                        var img = @String.Format("/Files/{0}/{1}/640x480/{2}", @album.NameAlbum, @mainPhoto.PhysicalName.Remove(@mainPhoto.PhysicalName.IndexOf('.')), @mainPhoto.PhysicalName);
                        <a href="@Url.Action("Details", "Album", new { id = @album.idalbum })">
                            <img class="album-photo" src="@img" alt="@album.NameAlbum"/>
                        </a>
                    }
                </div>
                <div class="ect-photos">
                    @{if (album.Photos.Where(p => p.Visible).ToArray().Length > 0)
                      {
                          var i = 0;
                          foreach (var photo in album.Photos.Where(p => p.Visible).TakeWhile(photo => i++ != 9))
                          {
                        <div class="mini-photo">
                            @{
                              var p = @String.Format("/Files/{0}/{1}/320x240/{2}", @photo.PhotoAlbum.NameAlbum, @photo.PhysicalName.Remove(@photo.PhysicalName.IndexOf('.')), @photo.PhysicalName);
                            }
                            <a href="@Url.Action("Details", "Album", new { id = @album.idalbum })">>
                                              <img src="@p" alt="@photo.FileName"/>
                            </a>
                        </div>
                          }
                      }
                    }
                </div>
            </div>
        </div>
           
            }
        }
    }
</div>
